<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:s="http://jboss.com/products/seam/taglib"
	xmlns:m="http://www.ol4jsf.org"
	xmlns:a4j="http://richfaces.org/a4j">

	<style>
		.noMaskClass .rich-mpnl-mask-div {
			display:none;
		}
		.contentEditData {
			width:100%;
			height:290px;
			overflow:auto;
		}
	</style>
	
	<rich:modalPanel id="spatialAnalysisToolbox" minWidth="500" minHeight="590" resizeable="false" styleClass="noMaskClass" zindex="10000">
		<f:facet name="header">
			<h:outputText value="#{messages['interactiveviewer.spatial_analysis_desc']}"/>
		</f:facet>
		
		<f:facet name="controls">
			<h:panelGroup>
				<h:graphicImage value="/img/close.png" styleClass="hidelink"
					id="hidePanel" />
				<rich:componentControl for="spatialAnalysisToolbox" attachTo="hidePanel"
					operation="hide" event="onclick" />
			</h:panelGroup>
		</f:facet>
		
		<h:panelGroup id="panelSpatialAnalysis">
			<h:form>
				<ui:include src="./includes/selectedZoneTlb.xhtml" />
			</h:form>
		</h:panelGroup>
		
		<h:form>
			<div align="center">
				<br />
				<strong>Tipo de relacion topologica</strong>
				<br />
				<rich:separator lineType="solid"/>
				<table cellspacing="10">
					<tr>
						<td>
							<h:selectBooleanCheckbox id="chkDistance" value="#{spatialAnalysisHelper.doDistance}" label="spatialanalysis.distance" />
							<h:outputLabel for="chkDistance" value="#{messages['spatialanalysis.distance']}"/>
							<br />
							<h:panelGrid columns="2">
								<h:outputText value="Distancia" />
								<rich:inputNumberSpinner value="#{spatialAnalysisHelper.distance}"/>
							</h:panelGrid>
						</td>
						<td valign="top">
							<h:selectBooleanCheckbox id="chkOverlaps" value="#{spatialAnalysisHelper.doOverlaps}" />
							<h:outputLabel for="chkOverlaps" value="#{messages['spatialanalysis.overlaps']}" />
						</td>
					</tr>
					<tr>
						<td>
							<h:selectBooleanCheckbox id="chkWithin" value="#{spatialAnalysisHelper.doWithin}" />
							<h:outputLabel for="chkWithin" value="#{messages['spatialanalysis.within']}" />
						</td>
						<td>
							<h:selectBooleanCheckbox id="chkTouches" value="#{spatialAnalysisHelper.doTouches}" />
							<h:outputLabel for="chkTouches" value="#{messages['spatialanalysis.touches']}" />
						</td>
					</tr>
					<tr>
						<td>
							<h:selectBooleanCheckbox id="chkCrosses" value="#{spatialAnalysisHelper.doCrosses}" />
							<h:outputLabel for="chkCrosses" value="#{messages['spatialanalysis.crosses']}" />
						</td>
						<td>
							<h:selectBooleanCheckbox id="chkContains" value="#{spatialAnalysisHelper.doContains}" label="Contiene a" />
							<h:outputLabel for="chkContains" value="#{messages['spatialanalysis.contains']}" />
						</td>
					</tr>
				</table>
				
				<br />
				<br />
				
				<strong>Tipo de analisis</strong>
				<br />
				<rich:separator lineType="solid"/>
				<h:panelGrid columns="1">
					<h:selectOneRadio value="" layout="pageDirection">
						<f:selectItem itemValue="1" itemLabel="Basado en grupo de reglas"/>
						<f:selectItem itemValue="0" itemLabel="Todas las interacciones posibles"/>
					</h:selectOneRadio>
				</h:panelGrid>
				
				<br />
				<br />
				
				<strong>Parametros del analisis espacial</strong>
				<br />
				<rich:separator lineType="solid"/>
				<br />
				<table style="width:95%">
					<tr>
						<td width="30%">Grupo de reglas</td>
						<td width="70%">
							<h:selectOneMenu value="#{spatialAnalysisHelper.ruleGroup}" converter="#{optionsHelper.permitRuleGroupConverter}" style="width:100%">
								<f:selectItems value="#{optionsHelper.spatialRuleGroupsSelectList}"/>
							</h:selectOneMenu>
						</td>
					</tr>
				</table>
				<br />
				<table style="width:95%">
					<tr>
						<th style="width:50%">Operando 1</th>
						<th style="width:50%">Operando 2</th>
					</tr>
					<tr>
						<td>
							<h:panelGroup id="grpOperand1">
								<h:panelGrid columns="2" rendered="#{interactiveViewerHelper.selectedZone != null}">
									<h:outputText value="Capa"/>
									<h:outputText value="#{generalHelper.formatLevelText(interactiveViewerHelper.selectedZone.level)}" style="color:Red;" />
									
									<h:outputText value="Uso" />
									<h:inputTextarea id="nameLandUse1"
										value="#{generalHelper.formatLandUseText(interactiveViewerHelper.selectedZone.landUse)}"
										rows="2"
										style="width:100%"
										readonly="true">
									</h:inputTextarea>
								</h:panelGrid>
								
								<h:panelGrid columns="2" rendered="#{interactiveViewerHelper.selectedZone == null}">
									<h:outputText value="Capa"/>
									<h:outputText value="#{messages['spatial_analysis.txt_no_zone_parcel_selected']}" style="color:Red;" />
									
									<h:outputText value="Uso" />
									<h:outputText value="#{messages['spatial_analysis.txt_no_zone_parcel_selected']}" style="color:Red;" />
								</h:panelGrid>
							</h:panelGroup>
						</td>
						<td>
							<h:panelGrid columns="2">
								<h:outputText value="Capa" />
								<h:selectOneMenu value="#{spatialAnalysisHelper.operand2Level}" converter="#{spatialRulesHelper.levelConverter}" style="width:100%">
									<f:selectItems value="#{spatialRulesHelper.levelList}"/>
								</h:selectOneMenu>
								
								<h:outputText value="Uso" />
								<h:inputTextarea id="nameLandUse2" value="" rows="2" style="width:100%" readonly="true" ondblclick="selectLandUse2();"/>
							</h:panelGrid>
						</td>
					</tr>
				</table>
				<br />
				<a4j:commandButton
					value="Aceptar"
					reRender="panelSpatialAnalysisResults"
					action="#{spatialAnalysisHelper.doNewSpatialAnalysis}">
					<f:setPropertyActionListener value="#{interactiveViewerHelper.selectedZone}" target="#{spatialAnalysisHelper.spatialZone}" />
				</a4j:commandButton>
			</div>
		</h:form>
		
		<h:form>
			<a4j:jsFunction
				name="selectLandUse2"
				action="#{selectLandUseHelper.setInputFields('x', 'nameLandUse2')}"
				reRender="sa:frmSelectLandUse"
				oncomplete="#{rich:component('sa:selectLandUsePanel')}.show()">
				<f:setPropertyActionListener
					target="#{selectLandUseHelper.landUseField}"
					value="spatialAnalysisHelper.operand2LandUse">
				</f:setPropertyActionListener>
			</a4j:jsFunction>
		</h:form>
	</rich:modalPanel>
	
	<f:subview id="sa">
		<ui:include src="/WEB-INF/includes/selectLandUse.xhtml" />
	</f:subview>
	
</ui:composition>

